﻿CREATE PROCEDURE [ServiceEngine].[ListOperationsBySchema]
	@SchemaID uniqueidentifier 
AS
BEGIN
	SET NOCOUNT ON;

	SELECT	
			N.[EntityID] as ID, 
			N.[EntityName] as [Name], 
			N.EntityDescription as Description
	FROM	[ServiceEngine].Names N
	JOIN	[ServiceEngine].OperationVersions OV on N.[EntityID] = OV.OperationID
	JOIN	[ServiceEngine].Operations O on O.OperationID = OV.OperationID
	JOIN	[ServiceEngine].MessageParts MP on OV.OperationVersionID = MP.OperationVersionID
	JOIN	[ServiceEngine].SchemaObjects SO on SO.SchemaObjectID = MP.SchemaObjectID
	WHERE	N.[EntityTypeID] = 4
	AND		SO.SchemaID = @SchemaID 
	AND		SO.DateRevised = NULL -- This is for the latest node
END


